/*
 * Copyright 2010-2012 Susanta Tewari. <freecode4susant@users.sourceforge.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package coalescent.cef.pui;

import cef.event.Event;
import cef.pui.EventConstructionException;
import cef.pui.EventImpl;
import cef.pui.pob.Builder;
import cef.pui.pob.BuilderException;

import coalescent.br.BRSPopGen;
import coalescent.br.BRWComp;
import coalescent.cef.event.RunBackwardRecursionEvent;
import coalescent.cef.pui.pob.Builders;

import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

/**
 * Implements {@code CheckPhylogenyEvent} using the following properties.
 * <ul>
 * <li>{@code coalescent.builder.BRSPopGen.delegate = coalescent.cef.pui.pob.Builders$BUILDER_BR_GT | coalescent.cef.pui.pob.Builders$BUILDER_BR_StringKC64Data}</li>
 * <li>{@code coalescent.builder.GTRecursion.theta = valid double string as specified in } {@link Double#parseDouble(java.lang.String)}</li>
 * <li>{@code coalescent.builder.GTRecursion.url = stringk69data:xml//URL}<a href="coalescent/cef/pui/pob/doc-files/k69data.xml.txt">file format</a>, must accompany the<a href="coalescent/cef/pui/pob/doc-files/k69data.xsd.txt">schema</a></li>
 * <li>{@code coalescent.builder.StringKC64Data.theta = valid double string as specified in } {@link Double#parseDouble(java.lang.String)}</li>
 * <li>{@code coalescent.builder.StringKC64Data.cnForm = valid values are of the format f1^t1_f2^t2... where fi and ti are positive and represent the frequency domain, and the alleles on that frequency domain, respectively}</li>
 * <li>{@code coalescent.builder.BRComputations.exactProb = true | false}</li>
 * <li>{@code coalescent.builder.BRComputations.configCounter = true | false}</li>
 * <li>{@code coalescent.builder.BRComputations.genealogyCounter = true | false}</li>
 * <li>{@code coalescent.builder.BRComputations.configBuilder = true | false}</li>
 * <li>{@code coalescent.builder.BRComputations.genealogyBuilder = true | false}</li>
 * </ul>
 *
 * @author Susanta Tewari
 * @version 2.0.0
 * @history Created on 12/06/2010 (RunBackwardRecursionEventImpl).
 * @since 1.3.0
 */
public final class RunBackwardRecursionEventImpl extends EventImpl
        implements RunBackwardRecursionEvent {


    // value objects

    /** Field description */
    private Builder<BRSPopGen<?, ?, ?, ?, ?, ?, ?>> brBuilder;

    /** Field description */
    private Builder<List<BRWComp<?, ?>>> brCompsBuilder;

    /**
     * Constructs ...
     *
     *
     * @param props
     *
     * @throws EventConstructionException
     */
    public RunBackwardRecursionEventImpl(Properties props) throws EventConstructionException {

        super(props);

        super.processEventProperties(getImplementedEventInterfaces());

        brBuilder = Builders.getBRSPopGenBuilder(props);

        addBuilder(brBuilder);

        brCompsBuilder = Builders.getBRComputationsBuilder(props);

        addBuilder(brCompsBuilder);
    }

    /**
     * Method description
     *
     *
     * @return
     */
    @Override
    protected List<Class<? extends Event>> getImplementedEventInterfaces() {

        List<Class<? extends Event>> result = new ArrayList<>(2);

        result.add(RunBackwardRecursionEvent.class);
        result.add(Event.class);

        return result;
    }

    /**
     * Method description
     *
     *
     * @return
     *
     * @throws BuilderException
     */
    @Override
    public BRSPopGen<?, ?, ?, ?, ?, ?, ?> getBackwardRecursion() throws BuilderException {
        return brBuilder.build();
    }

    /**
     * Method description
     *
     *
     * @return
     *
     * @throws BuilderException
     */
    @Override
    public List<BRWComp<?, ?>> getBRWalkerComputations() throws BuilderException {
        return brCompsBuilder.build();
    }
}
